/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.systemcar.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import br.com.systemcar.model.Posto;
import java.io.Serializable;
import java.util.List;
import javax.annotation.security.PermitAll;
import javax.ejb.Local;
import javax.ejb.Stateful;
import javax.persistence.Query;
import javax.resource.spi.SecurityPermission;



/**
 *
 * @author danilo
 */
@Stateless

public class PostoDao  {
     @PersistenceContext(unitName="SystemcarPU")
    private EntityManager em;
     
   
     public void salvar(Posto posto){
         em.persist(posto);
         
         
     }
     
     public List<Posto> listar(int userId){
         Query query =em.createNamedQuery("Posto.findByUsrId");
         query.setParameter("usrId", userId);
         List<Posto> lstPosto=query.getResultList();
         return lstPosto;
     }
//     public Posto pesquisar(){
//         Query query =em.createNamedQuery("Posto.findByPstId");
//         Posto posto = (Posto) query.getSingleResult();
//         return posto;
//   }
}
